/*
 * @Author: herw
 * @Date: 2020-07-16 11:20:04
 * @Last Modified by: herw
 * @Last Modified time: 2020-11-04 08:49:01
 */
import request from '@/utils/request'

export function getCodeImg() {
  return request({
    url: 'auth/code',
    method: 'get'
  })
}

// export function login(username, password, code, uuid) {
//   return request({
//     url: 'auth/login',
//     method: 'post',
//     data: {
//       username,
//       password,
//       code,
//       uuid
//     }
//   })
// }

export function login(username, password, code, uuid) {
  const form = {
    client_id: 'mobile-client',
    client_secret: 'mobile',
    username: username,
    password: password,
    grant_type: 'password',
    scope: 'read'
  }
  return request({
    url: 'oauth/token',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
      // 'Authorization': 'Basic bW9iaWxlLWNsaWVudDptb2JpbGU='
    },
    params: form
  })
}

export function getInfo(token) {
  return request({
    url: 'auth/info',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: 'auth/logout',
    method: 'delete'
  })
}
